package com.appspot.zcmjqm.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.appspot.zcmjqm.app.model.Contact;
import com.appspot.zcmjqm.service.ContactService;

@Controller
@RequestMapping("/contact")
public class ContactControllerWebMVCImpl implements ContactController {
	
	@Autowired
	private ContactService contactService;
	
	@RequestMapping("/display.do")
	public ModelAndView display() {
		ModelAndView mav = new ModelAndView();
		Contact contact = new Contact();
		mav.addObject("contact", contact);
		mav.setViewName("contact");
		return mav;
	}

	@RequestMapping("/send.do")
	public ModelAndView newContact(Contact contact) {
		ModelAndView mav = new ModelAndView();
		contactService.sendContact(contact);
		mav.setViewName("redirect:/home/show.do");
		return mav;
	}

	public void setContactService(ContactService contactService) {
		this.contactService = contactService;
	}

}